﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <title>Test</title>
    <script src="../../Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.ztree.core-3.5.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.ztree.exedit-3.5.js" type="text/javascript"></script>
    <link href="../../Content/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript">
        var zTree;
        var demoIframe;
        var setting = {
            view: {
                dblClickExpand: false,
                showLine: true,
                selectedMulti: false
            },
            data: {
                simpleData: {
                    enable: true,
                    idKey: "id",
                    pIdKey: "pId",
                    rootPId: ""
                }
            },
            callback: {
                beforeClick: function (treeId, treeNode) {
                    var zTree = $.fn.zTree.getZTreeObj("tree");
                    if (treeNode.isParent) {
                        zTree.expandNode(treeNode);
                        return false;
                    } else {
                        demoIframe.attr("src", treeNode.file);
                        return true;
                    }
                }
            }
        };



        function Show() {
        }
        var zNodes = [
             @Html.Raw(@TempData["ZTree"].ToString())
		];

        $(document).ready(function () {
            var t = $("#tree");
            t = $.fn.zTree.init(t, setting, zNodes);
            demoIframe = $("#testIframe");
            demoIframe.bind("load", loadReady);
            var zTree = $.fn.zTree.getZTreeObj("tree");
            zTree.selectNode(zTree.getNodeByParam("id", 1));

        });
        function showIconForTree(treeId, treeNode) {
            return !treeNode.isParent;
        };
        function loadReady() {
            var bodyH = demoIframe.contents().find("body").get(0).scrollHeight,
		    htmlH = demoIframe.contents().find("html").get(0).scrollHeight,
		    maxH = Math.max(bodyH, htmlH), minH = Math.min(bodyH, htmlH),
		    h = demoIframe.height() >= maxH ? minH : maxH;
            if (h < 530) h = 530;
            demoIframe.height(h);
        }

        function editNode(text) {
			var zTree = $.fn.zTree.getZTreeObj("tree");
			nodes = zTree.getSelectedNodes(),
			treeNode = nodes[0];
            treeNode.name = text;
            zTree.updateNode(treeNode);
		};
        function deleteNode(){
            var zTree = $.fn.zTree.getZTreeObj("tree");
			nodes = zTree.getSelectedNodes(),
			treeNode = nodes[0];
            var callbackFlag = $("#callbackTrigger").attr("checked");
			zTree.removeNode(treeNode, callbackFlag);
        }
        function AddNode(text){
         var zTree = $.fn.zTree.getZTreeObj("tree");
			nodes = zTree.getSelectedNodes(),
			treeNode = nodes[0];
            treeNode = zTree.addNodes(treeNode, {id:(100 + newCount), pId:treeNode.id, isParent:isParent, name:"\""+text+"\""});
        }
    </script>
    <style type="text/css">
        .ztree li a.level0
        {
            width: 162px;
            height: 25px;
            text-align: center;
            text-decoration: none;
            background-image: url(../../Content/Images/list_task.jpg);
        }
        .ztree li a.level0.cur
        {
            background-image: url(../../Content/Images/list_task.jpg);
        }
        .ztree li a.level0 span
        {
            font: 12px "宋体";
            color: #004C7E;
        }
        .ztree li a.level0 span.button
        {
            display: none;
        }
        .ztree li span.button.switch.level0
        {
            display: none;
        }
        
        
        
        .ztree li a.level1
        {
            border-bottom: 1px dotted #004C7E;
            height: 25px;
            width: 162px;
            margin-left: -20px;
            text-align: center;
            text-decoration: none;
        }
        .ztree li a.level1.cur
        {
        }
        .ztree li a.level1 span
        {
            font: 12px "宋体";
            color: #004C7E;
        }
        .ztree li a.level1 span.button
        {
            display: none;
        }
        .ztree li span.button.switch.level1
        {
            display: none;
        }
        
        body
        {
            margin: 0 auto;
            padding: 0;
            border: 0;
        }
    </style>
</head>
<body>
    <div style="background-color: skyblue; text-align: center; width: 162px; height: 600px;">
        <div style="background-image: url(../../Content/Images/list_top.gif); height: 28px;">
        </div>
        <div style="margin-left: -10px;">
            <ul id="tree" class="ztree" style="width: 260px; overflow: auto;">
            </ul>
        </div>
    </div>
</body>
</html>
